<?php 
/////////////////////////////////////////////////////////////////////////////
// 
//
// workflow_system
//
// workflow_copyright
// 
/////////////////////////////////////////////////////////////////////////////

/**
 * FILE_NAME : makehtml.class.php   FILE_PATH : \classes\libraries\makehtml.class.php
 * ....生成静态页面类
 *
 * @copyright workflow_system 
 * @author workflow Develop Team 
 * @package 
 * @subpackage 
 * @version Wed Dec 26 16:07:51 CST 2007
 */
class MakeHtml{

	function makefile($html_name, $template_name){
		ob_start();
		$tpl->display($template_name);
		$this_my_file = ob_get_contents();
		ob_end_clean();
		$file_name = $html_name."html";
		if($this->tohtmlfile($file_name, $this_my_file)){
			echo $file_name;
		}else{
			echo "faild";
		}

	}

	/**
	 * 生成文件
	 *
	 * @param string $file_name
	 * @param string $file_content
	 * @return string
	 */
	function tohtmlfile($file_name, $file_content)
	{
		$file_content = $file_content.'	';//防止信息为空
		if(is_file($file_name)){
			@unlink($file_name);
		}
		$file_handle = @fopen($file_name, "wb");
		if(!is_writable($file_name)){
			$error_report = "You don't have permission to access $file_name on this server!";
			echo  "{type:0,message:\"$error_report\"}";
			exit;
		}
		if(!fwrite($file_handle, $file_content)){
			$error_report = "You don't have permission to access $file_name on this server! Your file is empty";
			echo  "{type:0,message:\"$error_report\"}";
			exit;
		}
		fclose($file_handle);
		return $file_name;
	}
	/**
	 * 写入文件，安装程序使用（临时解决）
	 *
	 * @param string $file_name
	 * @param string $file_content
	 * @return string
	 */
	function installhtmlfile($file_name, $file_content)
	{
		$file_content = $file_content.'	';//防止信息为空
		$error_report = "";
		if(is_file($file_name)){
			@unlink($file_name);
		}
		$file_handle = @fopen($file_name, "wb");
		if(!is_writable($file_name)){
			$error_report = "请确保\" $file_name \"具有可写权限!";
		}
		if(!fwrite($file_handle, $file_content)){
			$error_report = "请确保 $file_name 具有可写权限并可被程序写入!";
		}
		fclose($file_handle);
		return $error_report;
	}
}


?>